package com.geekaca.d4.d3;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class Duration99 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的生日, 格式为: yyyy-MM-dd");
        String yourBirStr = scanner.next();
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime yourBirthDay = LocalDateTime.parse(yourBirStr + " 00:00:00", dtf);
//        System.out.println(cal99Days(yourBirthDay));

        System.out.println("你如果能活到99岁, 还剩" + cal99Days(yourBirthDay) + "天");
    }

    public static long cal99Days(LocalDateTime birthday) {
        // 当前日期
        LocalDateTime today = LocalDateTime.now();
        // 生日到99岁要经过的年数
        LocalDateTime expected = birthday.plusYears(99);
        // 计算duration
        Duration duration = Duration.between(today, expected);

        return duration.toDays();
    }
}
